package main

import (
	"fmt"
	"strconv"
	"strings"
)

//split
func split(){
	str := "a,b,c,d"
	s := strings.Split(str, ",")
	fmt.Println("____",s, len(str))
}

//取最大牌数组
func GetMaxCards() (cards []int32){
	strList := strings.Split("2,3,5,30,", ",")
	for _, v := range strList {
		n,_ := strconv.Atoi(v)
		fmt.Println(n)
		if n > 0 {
			cards = append(cards, int32(n))
		}
	}
	return
}


//最喜欢的盲注
func GetSBMap() map[float64]int{
	//0.5 1 2 5 10 25 50 100 200 500 1000
	//sb := []float32{0.5, 1, 2, 5, 10, 25, 50, 100, 200, 500, 10000}
	var maxk float64
	//LikeSB := "0.5:1,1:3,2:14,5:9,"
	LikeSB := ""
	mp := make(map[float64]int, 0)
	strList := strings.Split(LikeSB, ",")
	for _, v := range strList {
		if len(v) == 0 {
			continue
		}
		item := strings.Split(v, ":")
		//fmt.Println("item:", item)
		n, _ := strconv.Atoi(item[1])
		maxk,_ = strconv.ParseFloat(item[0], 32)
		mp[maxk] = n
	}
	fmt.Println("mp:", mp)
	return mp
}


//最喜欢的盲注
func GetLikeSB() float64{
	//0.5 1 2 5 10 25 50 100 200 500 1000
	//sb := []float32{0.5, 1, 2, 5, 10, 25, 50, 100, 200, 500, 10000}
	var maxv int = 0
	var maxk float64
	mp := GetSBMap()
	for k, v := range mp {
		if v > maxv {
			maxv = v
			maxk = k
		}
	}
	fmt.Println("maxk:", maxk)
	return maxk
}

func SetLikeSB(blind float64) {
	//现有的盲注
	mp := GetSBMap()
	mp[blind] += 1
	sbStr := ""
	for k, v := range mp {
		str := fmt.Sprintf("%v:%v",k,v)
		sbStr = sbStr + str + ","
	}
	fmt.Println("sbStr:", sbStr)
}

func main() {
	fmt.Println()
	split()
	cards := GetMaxCards()
	fmt.Println(cards)
	//GetSBMap()
	GetLikeSB()
	SetLikeSB(15)
}
